﻿#pragma once

#ifndef QCEFRENDERCLIENT_H
#define QCEFRENDERCLIENT_H

#include "QCefHeader.h"
#include "QCefV8Handler.h"
#include "QCefApp.h"
#include "QCefUtilV8.h"

class QCefRenderClient : public CefBaseRefCounted
{
public:
    QCefRenderClient(QCefApp * app = nullptr);
    virtual ~QCefRenderClient();

public:
    int init(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context);

    void AsyncExecuteNativeMethod(const CefV8ValueList & arguments);
    void reportJavaScriptResult(const CefV8ValueList & arguments);

protected:
    QCefApp*                    m_app;
    CefRefPtr<CefBrowser>       m_browser;
    CefRefPtr<CefFrame>         m_frame;
    CefRefPtr<QCefV8Handler>    m_v8Handler;
    CefRefPtr<CefV8Value>       m_reportFunc;

protected:
    //CefRefPtr<CefV8Value> CefValueToV8Value(CefValue * cefValue);
    //CefRefPtr<CefValue> V8ValueToCefValue(CefV8Value * v8Value);

private:
    IMPLEMENT_REFCOUNTING(QCefRenderClient);
};

#endif // QCEFRENDERCLIENT_H
